package com.example.wemedia.controller;

import com.example.wemedia.service.WmUserService;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.common.enums.AppHttpCodeEnum;
import com.usian.model.media.dtos.WmApUserDto;
import com.usian.model.media.pojos.WmUser;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "自媒体用户相关接口")
@Slf4j
@RequestMapping("/api/vi/wemedia")
public class WmUserController {
    @Autowired
    private WmUserService wmUserService;


    /**
     * 添加自媒体用户
     *
     * @param wmApUserDto
     * @return
     */
    @PostMapping("/add_wemedia_user")
    public ResponseResult addWeMediaUser(@RequestBody WmApUserDto wmApUserDto) {
        return wmUserService.addWmUser(wmApUserDto);
    }

    /**
     * 根据名称查询自媒体用户
     *
     * @param name
     * @return
     */
    @GetMapping("/get_wmuser_by_name")
    public ResponseResult getMediaUserByName(@RequestParam String name) {
        List<WmUser> wmUserList = wmUserService.findWmUserByName(name);
        return ResponseResult.okResult(wmUserList);
    }

}
